package org.pentaho.cubic.client.perspective.filedetails;

import java.util.Date;

import org.pentaho.cubic.client.perspective.fileproperties.FileItem;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;

public class DetailWrapper extends Composite {

	private static DetailWrapperUiBinder uiBinder = GWT
			.create(DetailWrapperUiBinder.class);

	interface DetailWrapperUiBinder extends UiBinder<Widget, DetailWrapper> {
	}

	public DetailWrapper() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField HTML fname;
	@UiField HTML ftype;
	@UiField HTML fdescription;
	@UiField HTML flocation;
	@UiField HTML fdate;
	@UiField HTML furl;
	
	public DetailWrapper(FileItem file) {
		initWidget(uiBinder.createAndBindUi(this));
		
		fname.setText(file.getLocalizedName());
		fdescription.setHTML(file.getDescription());
		flocation.setText(file.getPath());
		furl.setText(file.getURL());
		
		Date d = new Date(Long.parseLong(file.getLastModifiedDateStr()));
		
		fdate.setText(d.toString());
		
		
		if (file.isDirectory())
			ftype.setText("Folder");
		else
			ftype.setText(file.getFileType());
	}
}
